[Overview]cut, paste Examples
cut - remove sections from each line of files
cut OPTION... [FILE]...
-b<list>: select only these bytes
-c<list>: select only these characters
-d<delim>: use <delim> instead of TAB for field delimiter
-f<list>: select only these fields; also print any line that contains no
delimiter character, unless the -s option is specified
--complement: complement the set of selected bytes, characters or fields
-s: do not print lines not containing delimiters
--output-delimiter=<string>: use <string> as the output delimiter the
default is to use the in put delimiter
---
paste - merge lines of files
paste [OPTION]... [FILE]...
Write lines consisting of the sequentially corresponding lines from
each FILE, separated by TABs, to standard output.
With no FILE, or when FILE is -, read standard input.
-d<char>: use character <char> instead of TABs
for further information see the manual pages for cut(1), paste(1)
- projection on first and forth column of the file (delimiter: ,)
cut -d',' -f1,4 ../data/city.csv
[Output]
- delete column 1 and 4 (delimiter: ,)
cut -d',' --complement -f1,4 ../data/city.csv
[Output]
- retun the second and third character
seq 1000 1030 | cut -b2-3
[Output]
- retun the first two, and forth character
seq 1000 1030 | cut -b1-2,4
[Output]
- return the first two characters from each line
cut --complement -b3- ../data/city.csv
[Output]
- merges city.name.txt name and city.population.txt line by line
paste city.name.txt city.population.txt
[Output]
- combines two numbers (separated by ,) from input in a line
seq 10 21 | paste -d',' - -
[Output]
- combines three numbers (separted by , and :) from input in a line
seq 10 21 | paste -d',:' - - -
[Output]
examples assembled by andreas schmidt for the DBKDA 2021 conference